package com.hp.attendance.service;

import com.hp.attendance.dao.LeaveDao;
import com.hp.attendance.entity.Leave;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

public class LeaveService {
    private LeaveDao leaveDao = new LeaveDao();

    /**
     * 请假记录查询
     *
     * @return
     */
    public List<Leave> getList() throws SQLException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
        return leaveDao.getList();
    }

    /**
     * 根据员工编号查询出所对应员工姓名
     *
     * @param empNumber
     * @return
     */
    public List<Leave> getLeaveByNumber(int empNumber) throws SQLException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
        return leaveDao.getLeaveByNumber(empNumber);
    }

    /**
     * 查询请假表审核状态
     * @return
     */
    public List<Leave> getLeaveByStatus(String leaveStatus) throws SQLException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
        return leaveDao.getLeaveByStatus(leaveStatus);
    }

    /**
     * 根据Id获取请假表
     * @param id
     */
    public Leave getLeaveQueryOne(int id) throws SQLException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
       return leaveDao.getLeaveQueryOne(id);
    }

    /**
     * 审批和驳回
     * @param status
     * @param id
     */
    public void updateLeave(String status ,int id) throws SQLException, IOException, ClassNotFoundException {
        leaveDao.updateLeave(status,id);
    }
}
